import Vue from 'vue'
import VueRouter from 'vue-router'
import QueryRouter from '../views/QueryPage/router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login/views')
  },
  {
    path: '/main',
    name: 'main',
    component: () => import('../views/Layout'),
    redirect: { name: 'home' },

    children: [
      ...QueryRouter,
      {
        path: 'home',
        name: 'home',
        component: () => import('../views/HomePage/views')
      },
      {
        path: 'ticketList',
        name: 'ticketList',
        component: () => import('../views/ManuPage/views/TicketList')
      },
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('../views/Dashboard/views')
      },
      {
        path: 'gallery',
        name: 'gallery',
        component: () => import('../views/ConsumerPage/views/Gallery')
      },
      {
        path: 'waterList',
        name: 'waterList',
        component: () => import('../views/ManuPage/views/WaterList')
      },
      {
        path: 'launchList',
        name: 'launchList',
        component: () => import('../views/ManuPage/views/LaunchList')
      },
      {
        path: 'catchList',
        name: 'catchList',
        component: () => import('../views/ManuPage/views/CatchList')
      },
      {
        path: 'createBox',
        name: 'createBox',
        component: () => import('../views/ManuPage/views/CreateBox')
      },
      {
        path: 'boxDetail',
        name: 'boxDetail',
        component: () => import('../views/ManuPage/views/BoxDetail')
      },
      {
        path: 'editBox',
        name: 'editBox',
        component: () => import('../views/ManuPage/views/EditBox')
      },
      {
        path: 'createExam',
        name: 'createExam',
        component: () => import('../views/ExaminerPage/views/CreateExam')
      },
      {
        path: 'examDetail',
        name: 'examDetail',
        component: () => import('../views/ExaminerPage/views/ExamDetail')
      },
      {
        path: 'createBuy',
        name: 'createBuy',
        component: () => import('../views/BuyerPage/views/CreateBuy')
      },
      {
        path: 'buyDetail',
        name: 'buyDetail',
        component: () => import('../views/BuyerPage/views/BuyDetail')
      },
      {
        path: 'createConsumer',
        name: 'createConsumer',
        component: () => import('../views/ConsumerPage/views/CreateConsumer')
      },
      {
        path: 'consumerDetail',
        name: 'consumerDetail',
        component: () => import('../views/ConsumerPage/views/ConsumerDetail')
      },
      {
        path: 'consumerList',
        name: 'consumerList',
        component: () => import('../views/ConsumerPage/views/MainList')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
export default router
